package cn.com.headfree.menu;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.callback.call.CommRoleServerCall;

@Controller
@RequestMapping(value = "/commonMenu", produces = "application/json;charset=UTF-8")
public class CommonMenuController extends ExBaseController {
	private static final Logger LOG = LogManager.getLogger(CommonMenuController.class);
	@Autowired
	private CommRoleServerCall commRoleServerCall;
	
	@RequestMapping("/findUserResourceByInterface/{resId}/{userId}/{code}")
    @ResponseBody
    public ResultData findUserResourceByInterface(HttpServletRequest request,HttpServletResponse response,@PathVariable("resId") String resId,@PathVariable("userId") String userId,@PathVariable("code") String code) {
		ResultData result = new ResultData();
		try {
			LOG.info("调用human-manage成功！==================resId="+resId+",================userId="+userId+",===================code="+code);
			result=commRoleServerCall.findUserResourceByInterface(resId, userId, code);
			System.out.println("获取到的结果:"+result);
			LOG.info("成功获取公共框架返回的菜单数据:"+result);
        } catch (Exception e) {
            result.setErrorMsg("获取用户对应菜单按钮异常");
            result.setSuccess(false);
            LOG.error("获取用户对应菜单按钮异常", e);
        }
        return result;
	}
}
